package Cluster;

import java.util.ArrayList;

import XmlLoader.FGObjectStructure;
import XmlLoader.FGObjectTrajectoryStructure;
import XmlLoader.Position;
import XmlLoader.Size;

public class Trajectory {
	public int traj_id = 0, seg_id = 0;
	public ArrayList<Position> listPoint = null;
	public ArrayList<Size> listSize = null;
	
	public Trajectory() {
		this.listPoint = new ArrayList<Position>();
		this.listSize = new ArrayList<Size>();
	}
	
	public Trajectory(FGObjectTrajectoryStructure getTraj, 
			int seg_id ,int start, int pointNum) {
		int index = start;
		this.listPoint = new ArrayList<Position>();
		this.listSize = new ArrayList<Size>();
		while(index < pointNum) {
			FGObjectStructure getFS =  getTraj.GET003_elementIn_list_fGObject(index);
			Position newP = new Position(getFS.GET001_centerReal().x, getFS.GET001_centerReal().y);
			Size newSize = getFS.GET006_boxSize();
			
			this.traj_id = getTraj.GET001_nobjNewNumIndex();
			this.seg_id = seg_id;
			this.listPoint.add(newP);
			this.listSize.add(newSize);
			index = index + 1;
		}
	}
	
	public void ACT001_addPoint(int x, int y) {
		this.listPoint.add(new Position(x,y));
	}
	
	public void ACT001_addPoint(Position p) {
		this.listPoint.add(p);
	}
	
	public int GET001_length() {
		return this.listPoint.size();
	}
	
	public Position GET002_point(int index) {
		return this.listPoint.get(index);
	}
	
	public int GET003_trajID() {
		return this.traj_id;
	}
	
	public Size GET004_size(int index) {
		return this.listSize.get(index);
	}
	
	public Trajectory GET003_newSameOne() {
		Trajectory newTraj = new Trajectory();
		int index = 0;
		while(index < this.listPoint.size()) {
			newTraj.ACT001_addPoint(new Position(this.GET002_point(index).x,
					this.GET002_point(index).y));
			index = index + 1;
		}
		return newTraj;
	}
}
